# from googletrans import Translator
import goslate

def translate_text(input_path, output_path):
    # translator = Translator()
    gs = goslate.Goslate()
    with open(input_path, 'r') as input_file, open(output_path, 'w') as output_file:
        for line in input_file:
            # translation = translator.translate(line, src='en', dest='zh-cn').text
            translation = gs.translate(line, 'zh')
            print(translation)
            output_file.write(translation + '\n')


# 示例用法
input_path = "./folder/en_speech.txt"
output_path = "./folder/output.txt"

translate_text(input_path, output_path)
